﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NhomNguoiDung.aspx.cs" Inherits="Viewer.NhomNguoiDung.NhomNguoiDung" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register Src="UserControls/UCNhomNguoiDung.ascx" TagName="UCNhomNguoiDung" TagPrefix="uc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link href="../resources/css/main.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function ConfirmDelete(id) {
            Ext.MessageBox.show({
                title: 'Confirm',
                msg: 'Bạn có chắc chắn xóa record này ko?',
                icon: Ext.MessageBox.QUESTION,
                buttons: Ext.MessageBox.YESNO,
                fn: function(btn) {
                    if (btn.toLowerCase() == 'yes') {
                        X.Delete(id);
                    }
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:ResourceManager Locale="vi" ID="ResourceManager1" runat="server"  DirectMethodNamespace="X" >
        <Listeners>
            <BeforeAjaxRequest Handler="Ext.net.Mask.show();" />
            <AjaxRequestComplete Handler="Ext.net.Mask.hide();" />
            <AjaxRequestException Handler="Ext.net.Mask.hide();" />
        </Listeners>
    </ext:ResourceManager>
        <ext:Panel runat="server" Layout="Fit" MonitorResize="true" BodyStyle="background-color:white;">
        <Items>
            <ext:GridPanel ID="grdNhomNguoiDung" runat="server" Height="560" AutoExpandColumn="TenNhomNguoiDung"
                StripeRows="true" MonitorResize="true" Width="400">
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:CommandColumn Width="40" ColumnID="Command" Locked="true">
                            <Commands>
                                <ext:GridCommand>
                                    <Menu>
                                        <Items>
                                            <ext:MenuCommand Text="Xem chi tiết" CommandName="View" Icon="LayoutHeader" />
                                            <ext:MenuCommand Text="Sửa" CommandName="Edit" Icon="ApplicationEdit" />
                                            <ext:MenuCommand Text="Xóa" CommandName="Delete" Icon="Delete" Cls="menuItemTop" />
                                        </Items>
                                    </Menu>
                                </ext:GridCommand>
                            </Commands>
                        </ext:CommandColumn>
                        <ext:Column Header="Tên Nhóm Người Dùng" DataIndex="TenNhomNguoiDung" />
                        <%--<ext:Column Header="Nhóm Người Dùng" DataIndex="TenLoaiNhomNguoiDung" Width="200" />--%>
                        <ext:Column Header="Ghi Chú" DataIndex="GhiChu" Resizable="true" Width="300" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true" />
                </SelectionModel>
                <Listeners>
                    <Command Handler="if(command=='View'){#{DirectMethods}.ShowDialogDetail(record.id);} 
                                      else if(command=='Edit'){#{DirectMethods}.ShowDialogEdit(record.id);}
                                      else if(command=='Delete'){ConfirmDelete(record.id);}" />
                </Listeners>
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageIndex="1" PageSize="20"
                        HideRefresh="true">
                    </ext:PagingToolbar>
                </BottomBar>
                <TopBar>
                    <ext:Toolbar ID="Toolbar" runat="server" LabelAlign="Right">
                        <Items>
                            <ext:Button ID="btnAdd" runat="server" Text="Tạo mới" IconAlign="Left" Icon="Add">
                                <DirectEvents>
                                    <Click OnEvent="btnAddNew_Click">
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Store>
                    <ext:Store ID="storeNhomNguoiDung" runat="server">
                        <Reader>
                            <ext:JsonReader IDProperty="NhomNguoiDungID">
                                <Fields>
                                    <ext:RecordField Name="NhomNguoiDungID" />
                                    <ext:RecordField Name="TenNhomNguoiDung" />
                                    <%--<ext:RecordField Name="LoaiNhomNguoiDungID" />
                                    <ext:RecordField Name="TenLoaiNhomNguoiDung" />--%>
                                    <ext:RecordField Name="GhiChu" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
            </ext:GridPanel>
        </Items>
    </ext:Panel>
    <uc:UCNhomNguoiDung ID="winUCNhomNguoiDung" runat="server" />
    </form>
</body>
</html>
